var App = require('app');

App.AppRunView = Em.View.extend({

    templateName: 'templates/app/run',
    didInsertElement: function() {
    	var me = this;
    	AppUtil.createSession(Vari.CurrAppId);
    	
    	var t = $("#displayUrl");
    	
    	t.click(function(){
        	t.focus();
        	t.select();
    	});
    	
    	me.charts = Ember.Map.create();
    	me.genReport();
    	setInterval(function() {
    		me.genReport();
    	}, 5000);
    },
    genReport: function() {
		var me = this;		
		
		if (Util.isEmpty(Vari.CurrPushFormId)) {
			return false;
		}
		
		me.charts.forEach(function(k, v) {
			var h = $("#chart_canvas_view #" + k).highcharts();
			if (h) h.destroy();
		});
    	Vari.rpt = FormUtil.retriveReport(Vari.CurrPushFormId);
    	Chart.genChart(me, "100%", "400px");    	
    }
});